package com.bluezone.dec.system.controller;

import com.bluezone.dec.common.CacheConstant;
import com.bluezone.dec.common.JsonResult;
import com.bluezone.dec.common.SystemConstant;
import com.bluezone.dec.system.service.MajorHazardSourceStatisticsService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * @Description 重大危险源统计controller
 * @Author chenzhaoming
 * @CreateDate 2018/11/6 11:36
 * @Company 浙江航天恒嘉数据科技有限公司
 */
@Api(tags = "重大危险源统计")
@RequestMapping("/dec/major-danger")
@RestController
public class MajorHazardSourceStatisticsController {

    @Autowired
    private MajorHazardSourceStatisticsService majorHazardSourceService;


    @ApiOperation("获取标题卡片的数据")
    @GetMapping("/title")
    public JsonResult getMajorCardData() {
        return new JsonResult().ok(majorHazardSourceService.majorHazard());
    }


    @ApiOperation("获取环形图的数据")
    @GetMapping("/ring")
    public JsonResult getMajorDoughnutData() {
        List<Map<String, Object>> ringData = new ArrayList<>();
        ringData.add(majorHazardSourceService.scaleLevel());
        ringData.add(majorHazardSourceService.dangerLevelStatistics());
        ringData.add(majorHazardSourceService.dangerLevelEnterprise());
        return new JsonResult().ok(ringData);
    }


    @ApiOperation("获取重大危险源行业数据")
    @GetMapping("/industry")
    public JsonResult getMajorDangerIndustryData() {
        return new JsonResult().ok(majorHazardSourceService.industry());
    }


    @ApiOperation("重大危险源活动类型占比分析")
    @GetMapping("/activity")
    public JsonResult getMajorActivityType() {
        return new JsonResult().ok(majorHazardSourceService.getType(SystemConstant.ACTIVITY_TYPE,CacheConstant.MAJOR_ACTIVITY_TYPE));
    }

    @ApiOperation("重大危险源可能引发事故的类型统计")
    @GetMapping("/accident")
    public JsonResult getAccidentType() {
        return new JsonResult().ok(majorHazardSourceService.getType(SystemConstant.ACCIDENT_TYPE,CacheConstant.MAJOR_TYPE));
    }

    @ApiOperation("重大危险源按级别增长情况分析")
    @GetMapping("/level")
    public JsonResult getMajorLevelAnalysis() {
        return new JsonResult().ok(majorHazardSourceService.getMajorGrowthAnalysis(SystemConstant.DANGER_LEVEL,CacheConstant.MAJOR_LEVEL_INCREASE));
    }

    @ApiOperation("重大危险源可能引发事故类别增长情况分分析")
    @GetMapping("/accident-type")
    public JsonResult getAccidentAnalysis() {
        return new JsonResult().ok(majorHazardSourceService.getMajorGrowthAnalysis(SystemConstant.ACCIDENT_TYPE,CacheConstant.MAJOR_TYPE_INCREASE));
    }


}
